GtkMenuSectionBox: Always show separators for labeled sections
authorMatthias Clasen <mclasen@redhat.com>
Tue, 29 Apr 2014 15:48:52 +0000 (11:48 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 29 Apr 2014 16:19:53 +0000 (12:19 -0400)
...unless they are empty.

gtk/gtkmenusectionbox.c
tests/popover.ui

index 62ab3182e25ebfd4f47f04425a24641327023c90..935ddf51af227e63705c4ec9306182f3e37ea88d 100644 (file)
@@ -84,16 +84,21 @@ gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
                                       gint              *n_items)
 {
   gboolean should_have_separator;
+  gboolean has_separator;
+  gboolean has_label;
   gint n_items_before = *n_items;
 
   gtk_container_foreach (GTK_CONTAINER (box->item_box), gtk_menu_section_box_sync_item, n_items);
 
-  should_have_separator = n_items_before > 0 && *n_items > n_items_before;
-
   if (box->separator == NULL)
     return;
 
-  if (should_have_separator == (gtk_widget_get_parent (box->separator) != NULL))
+  has_separator = gtk_widget_get_parent (box->separator) != NULL;
+  has_label = !GTK_IS_SEPARATOR (box->separator);
+
+  should_have_separator = (has_label || n_items_before > 0) && *n_items > n_items_before;
+
+  if (should_have_separator == has_separator)
     return;
 
   if (should_have_separator)
index 74fa0bfadb56546d5b06af78e1e7d2067e0c81c7..f9a843e444dae1ae35e9c211fd817afe196d3bc0 100644 (file)
@@ -1,7 +1,8 @@
 <interface>
   <menu id="menu">
     <section>
-      <attribute name="display-hint">horizontal-buttons</attribute>
+      <!--<attribute name="display-hint">horizontal-buttons</attribute>-->
+      <attribute name="label">Edit</attribute>
       <item>
         <attribute name="label">Cut</attribute>
         <attribute name="action">top.cut</attribute>